/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nattakute.model;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.codehaus.jackson.annotate.JsonBackReference;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonManagedReference;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 *
 * @author simple7211
 */
@Entity
@Table(name = "timetable")

public class Timetable implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Size(min = 1, max = 15)
    @Column(name = "timeTableID")
    private Integer timeTableId;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "startTime")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
    @Temporal(TemporalType.TIMESTAMP)
    private Date startTime;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "endTime")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
    @Temporal(TemporalType.TIMESTAMP)
    private Date endTime;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "active")
    private boolean active;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "haslearn")
    private boolean haslearn;
    
    @JsonManagedReference
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "timeTable", fetch = FetchType.LAZY)
    private Set<Request> requests;
    
    @JoinColumn(name = "classID", referencedColumnName = "classID")
    @JsonBackReference
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Classes classs;
    
    @JsonBackReference
    @JoinColumn(name = "labID", referencedColumnName = "labID")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Lab lab;

    @Basic(optional = false)
    @NotNull
    @Column(name = "shifts")
    private String shifts;
    
    public Timetable() {
    }

    public Timetable(Integer timeTableId) {
        this.timeTableId = timeTableId;
    }


    

    public Integer getTimeTableId() {
		return timeTableId;
	}

	public void setTimeTableId(Integer timeTableId) {
		this.timeTableId = timeTableId;
	}

	public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

   

    public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public boolean isHaslearn() {
		return haslearn;
	}

	public void setHaslearn(boolean haslearn) {
		this.haslearn = haslearn;
	}

	
    
	@JsonIgnore
    public Set<Request> getRequests() {
		return requests;
	}

	public void setRequests(Set<Request> requests) {
		this.requests = requests;
	}

	public Classes getClasss() {
		return classs;
	}

	public void setClasss(Classes classs) {
		this.classs = classs;
	}

	public Lab getLab() {
		return lab;
	}

	public void setLab(Lab lab) {
		this.lab = lab;
	}

	public String getShifts() {
		return shifts;
	}

	public void setShifts(String shifts) {
		this.shifts = shifts;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (timeTableId != null ? timeTableId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Timetable)) {
            return false;
        }
        Timetable other = (Timetable) object;
        if ((this.timeTableId == null && other.timeTableId != null) || (this.timeTableId != null && !this.timeTableId.equals(other.timeTableId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.da.model.Timetable[ timeTableID=" + timeTableId + " ]";
    }
    
}
